package com.hhkj.admin.invoice.domain;

import cn.afterturn.easypoi.excel.annotation.Excel;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BizBaseEntity;
import com.ruoyi.common.valid.VAdd;
import com.ruoyi.common.valid.VEdit;
import lombok.Data;
import lombok.EqualsAndHashCode;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;

/**
 * 记录订单每次开票信息
 */
@EqualsAndHashCode(callSuper = true)
@TableName(value = "s_invoice")
@Data
public class Invoice extends BizBaseEntity {

    /** 订单id */
    @NotNull(message = "订单id不能为空", groups = {VAdd.class})
    private Long orderId;

    /** 抬头id */
    private Long titleId;

    /** 开票金额 **/
    @Excel(name = "开票金额", orderNum = "5", width = 30, type = 10, numFormat = "#,##0.00")
    private BigDecimal price;

    /**
     * 订单编号， 关联s_order
     */
    @TableField(value = "order_num")
    @Excel(name = "关联订单", orderNum = "0", width = 30)
    private String orderNum;

    /**
     * 发票类型："ordinaryElectronic"-普通电子发票
     */
    @TableField(value = "type_code")
    private String typeCode;

    /**
     * 发票类型："person"-个人 "enterprise"-企业
     */
    @TableField(value = "title_type_code")
    @NotBlank(message = "发票类型不能为空", groups = {VAdd.class})
    private String titleTypeCode;

    /**
     * 发票抬头
     */
    @TableField(value = "title")
    @NotBlank(message = "发票抬头不能为空", groups = {VAdd.class})
    @Excel(name = "发票抬头", orderNum = "3", width = 30)
    private String title;

    /**
     * 纳税识别号
     */
    @TableField(value = "tax_identification_number")
    @Excel(name = "纳税识别号", orderNum = "4", width = 30)
    private String taxIdentificationNumber;

    /**
     * 企业地址
     */
    @TableField(value = "address")
    private String address;

    /**
     * 企业电话
     */
    @TableField(value = "mobile")
    private String mobile;

    /**
     * 开户行
     */
    @TableField(value = "bank_name")
    private String bankName;

    /**
     * 银行账号
     */
    @TableField(value = "bank_account")
    private String bankAccount;

    /**
     * 发票编号
     */
    @TableField(value = "invoice_number")
    @Excel(name = "发票编号", orderNum = "2", width = 30)
    private String invoiceNumber;

    /**
     * 发票状态："non"-未生效 "effective"-有效 "invalid"-作废 "reapplied"-已经重新申请
     */
    @TableField(value = "status_code")
    private String statusCode;

    /**
     * 作废时间
     */
    @TableField(value = "invalid_time")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date invalidTime;

    /**
     * 开票时间
     */
    @TableField(value = "invoicing_Date")
    @JsonFormat(pattern = "yyyy-MM-dd")
    @Excel(name = "开票日期", orderNum = "6", width = 30, format = "yyyy-MM-dd")
    private Date invoicingDate;

    /**
     * 发票图片url
     */
    @TableField(value = "invoice_url")
    @NotBlank(message = "发票图片不能为空", groups = {VEdit.class})
    private String invoiceUrl;

    /** 销售id */
    private Long saleId;

    @Override
    @NotNull(message = "id不能为空", groups = {VEdit.class})
    public Long getId() {
        return super.getId();
    }
}